﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Manage_ChangePassword : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void SaveButton_Click(object sender, EventArgs e)
    {
        string id = Session["Current_User_Id"].ToString();
        string old = OldText.Text.Trim();
        string pas = NewText.Text.Trim();

        TreasurerDataContext db = new TreasurerDataContext();
        Users u = (from aU in db.Users
                   where aU.ID == id
                   select aU).First();

        if (u.Password != old)
        {
            ErrorText.Text = "旧密码输入错误，请重新输入。";
        }
        else
        {
            u.Password = pas;
            db.SubmitChanges();

            Response.Write("<script>alert('密码修改成功，下次登录请使用新密码。');document.location='./EditUser.aspx?uid=" + u.ID + "';</script>");
        }
    }
}